package com.wsx.java.boddy.simple;

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.matcher.ElementMatchers;

/**
 * @author wangshuaixin
 * @Title: com.wsx.java.boddy.simple.Simple
 * @Description: TODO
 * @date 2019/01/23
 */
public class Simple {

    public static void main(String[] args) throws Exception {
        String value = new ByteBuddy()
                .subclass(Source.class)
                .method(ElementMatchers.named("hello"))
                .intercept(MethodDelegation.to(Target.class))
                .make()
                .load(Simple.class.getClassLoader())
                .getLoaded()
                .newInstance()
                .hello("zhang");

        System.out.println(value);
    }
}
